import request from '@/utils/request'
import service from "@/utils/request.js"

export function login(data) {
  return request({
    url: '/auth/login',
    method: 'get',
    params: { 'username': data.username, 'passward': data.password, 'vercode': data.vercode,"key": data.key }
  })
}

// export function getInfo(token) {
//   return request({
//     url: '/user/info',
//     method: 'get',
//     params: { token }
//   })
// }

export function logout(token) {
  return request({
    url: '/user/logout',
    params:{"token": token},
    method: 'get'
  })
}

export function vercode() {
  return request({
    url: '/auth/vercode',
    method: 'get'
  })
}

export const getInfo = params => {
    return service.post(`/user/info`, params);
};

// 用户管理
export const getUserListPage = params => {
    return service.get(`/user/get`, {params: params});
};
export const removeUser = params => {
    return service.delete(`/user/delete`, {params: params});
};
export const editUser = params => {
    return service.put(`/user/put`, params);
};
export const addUser = params => {
    return service.post(`/user/post`, params);
};
export const batchRemoveUser = params => {
    return service.delete(`/Claims/BatchDelete`, {params: params});//没做
};

// 角色管理
export const getRoleListPage = params => {
    return service.get(`/role/get`, {params: params});
};
export const removeRole = params => {
    return service.delete(`/role/delete`, {params: params});
};
export const editRole = params => {
    return service.put(`/role/put`, params);
};
export const addRole = params => {
    return service.post(`/role/post`, params);
};

// 接口模块管理
export const getModuleListPage = params => {
    return service.get(`/module/get`, {params: params});
};
export const removeModule = params => {
    return service.delete(`/module/delete`, {params: params});
};
export const editModule = params => {
    return service.put(`/module/put`, params);
};
export const addModule = params => {
    return service.post(`/module/post`, params);
};


// 菜单模块管理
export const getPermissionListPage = params => {
    return service.get(`/permission/get`, {params: params});
};
export const getPermissionTreeTable = params => {
    return service.get(`/permission/GetTreeTable`, {params: params});
};
export const removePermission = params => {
    return service.delete(`/permission/delete`, {params: params});
};
export const editPermission = params => {
    return service.put(`/permission/put`, params);
};
export const addPermission = params => {
    return service.post(`/permission/post`, params);
};
export const getPermissionTree = params => {
    return service.get(`/permission/getpermissiontree`, {params: params});
};
export const getPermissionIds = params => {
    return service.get(`/permission/GetPermissionIdByRoleId`, {params: params});
};

export const addRolePermission = params => {
    return service.post(`/permission/assign`, params);
};
export const getNavigationBar = params => {
    return service.get(`/permission/GetNavigationBar`, {params: params}).then(res => res);
};
